import request from "./request";

// 登陆
export const login = async ({
  email,
  password
}) => {
  const res = await request({
    url: '/login/',
    method: 'post',
    data: {
      email,
      password
    }
  });

  return res;
};

// 注册
export const register = async ({
  email, invite_code
}) => {
  const res = await request({
    url: `/register/?email=${email}&invite_code=${invite_code}`,
    method: 'get',
    cancelOff: true
  });
  return res;
};

// 当前用户信息
export const getUserInfoApi = async ({
  user_id
}) => {
  // const res = await request({
  //   url: `/user/`,
  //   method: 'get',
  //   data: {
  //     user_id
  //   }
  // });

  return {
    "code": 0,
    "data": [
      {
        "city": "None",
        "company_id": 3,
        "country": "None",
        "create_time": "2024-08-15 09:14:34",
        "email": "james.zou@bitoss.cn",
        "invitation_code": "434242453333",
        "invite_code": "None",
        "lang": "zhCN",
        "user_id": 4
      }
    ],
    "message": "Success!"
  }
};

// 忘记密码获取验证码
export const getForgotPasswordEmailCode = async ({ email }) => {
  const res = await request({
    url: '/public/reset/password/verify_code',
    method: 'get',
    data: {
      email
    }
  });

  return res;
};

// 修改密码
export const resetPasswordApi = async ({
  email,
  password,
  verify_code
}) => {
  const res = await request({
    url: '/user/reset_password',
    method: 'post',
    data: {
      email,
      password,
      verify_code
    }
  });

  return res;
};
